package com.example.mybatisplus.web.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.mybatisplus.common.JsonResponse;
import com.example.mybatisplus.service.AdminService;
import com.example.mybatisplus.model.domain.Admin;


/**
 *
 *  前端控制器
 *
 *
 * @author lxp
 * @since 2021-06-17
 * @version v1.0
 */
@RestController
@RequestMapping("/api/admin")
public class AdminController {

    private final Logger logger = LoggerFactory.getLogger( AdminController.class );

    @Autowired
    private AdminService adminService;

    @GetMapping("/getById/{id}")
    public JsonResponse getById(@PathVariable("id") Long id){
        return JsonResponse.success(adminService.getById(id));
    }

    @PostMapping("/saveAdmin")
    public JsonResponse save(@RequestBody Admin admin){
        adminService.save(admin);
        return JsonResponse.success("ok");
    }
    //ahdhadhahs
    //安居客的绿卡就是看到了
    //我也写代码
}

